package gui;

import java.awt.Component;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowListener;
import javax.swing.JFrame;




public class GUI
{
   private JFrame frame;

   public GUI()
   {
      initialize();
   }

   private void initialize()
   {
      frame = new JFrame();
      frame.setBounds(100, 100, 829, 553);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.getContentPane().setLayout(null);

      frame.addKeyListener(new KeyAdapter() {
	 @Override
	 public void keyPressed(KeyEvent e)
	 {
	    try {
	       if (e.getKeyCode() == KeyEvent.VK_W && e.isControlDown()) frame.dispose();
	    } catch (Throwable t) {
	       System.out.println("Error when key pressed:");
	       t.printStackTrace();
	    }
	 }
      });

      frame.setVisible(true);
   }

   public void addKeyListener(KeyListener keyListener)
   {
      frame.addKeyListener(keyListener);
   }

   public void addWindowListener(WindowListener windowListener)
   {
      frame.addWindowListener(windowListener);
   }

   public void addComponent(Component comp)
   {
      frame.add(comp);
      frame.repaint();
   }
}
